package com.ly.honor.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ly.honor.entity.PlayerPlace;
import com.ly.honor.entity.dto.PlayerPlaceCreateDTO;
import com.ly.honor.entity.dto.PlayerPlaceEditDTO;
import com.ly.honor.entity.vo.PlayerPlaceQueryVO;
import com.ly.honor.exception.HonorException;
import com.ly.honor.service.PlayerPlaceService;
import com.ly.honor.mapper.PlayerPlaceMapper;
import com.ly.honor.util.ResultEnum;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
* @author 17798
* @description 针对表【bs_player_place】的数据库操作Service实现
* @createDate 2022-11-16 11:49:49
*/
@Service
public class PlayerPlaceServiceImpl extends ServiceImpl<PlayerPlaceMapper, PlayerPlace>
    implements PlayerPlaceService{

    @Autowired
    private PlayerPlaceMapper playerPlaceMapper;

    @Override
    public Page<PlayerPlaceQueryVO> selectPlayerPlacePage(long pageNum, long pageSize) {
        Page<PlayerPlaceQueryVO> page = new Page<PlayerPlaceQueryVO>(pageNum, pageSize);
        var playerPlaceQueryVOPage = playerPlaceMapper.selectPlayerPlacePage(page, pageNum, pageSize);

        return playerPlaceQueryVOPage;
    }

    @Override
    public PlayerPlaceQueryVO getPlayerPlaceById(long id) {
        PlayerPlaceQueryVO playerPlaceQueryVO = playerPlaceMapper.getPlayerPlaceById(id);
        return playerPlaceQueryVO;
    }

    @Override
    public void insertPlayerPlace(PlayerPlaceCreateDTO playerPlaceCreateDTO) {
        if(ObjectUtils.isEmpty(playerPlaceCreateDTO)){
            throw new HonorException(ResultEnum.OBJECT_NOT_NULL);
        }
        playerPlaceMapper.insertPlayerPlace(playerPlaceCreateDTO);

    }

    @Override
    public void updatePlayerPlace(PlayerPlaceEditDTO playerPlaceEditDTO) {
        if(ObjectUtils.isEmpty(playerPlaceEditDTO)){
            throw new HonorException(ResultEnum.OBJECT_NOT_NULL);
        }
        playerPlaceMapper.updatePlayerPlace(playerPlaceEditDTO);
    }

    @Override
    public List<PlayerPlace> selectPlaceAll(long gameId) {
        List<PlayerPlace> playerPlaceList = playerPlaceMapper.selectPlaceAll(gameId);
        return playerPlaceList;
    }
}




